package com.platform.service.impl;

import com.platform.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import com.platform.dao.StandingsTypeDao;
import com.platform.entity.StandingsTypeEntity;
import com.platform.service.StandingsTypeService;

/**
 * Service实现类
 *
 * @author ocean
 * @email 1141736487@qq.com
 * @date 2019-03-15 15:36:19
 */
@Service("standingsTypeService")
public class StandingsTypeServiceImpl implements StandingsTypeService {
    @Autowired
    private StandingsTypeDao standingsTypeDao;

    @Override
    public StandingsTypeEntity queryObject(Integer id) {
        return standingsTypeDao.queryObject(id);
    }

    @Override
    public StandingsTypeEntity queryByCodeAndUser(String code, Long createUser){
        return standingsTypeDao.queryByCodeAndUser(code,createUser);
    }

    @Override
    public List<StandingsTypeEntity> queryList(Map<String, Object> map) {
        Long userId = ShiroUtils.getUserId();
        if(userId == 1){
            map.put("createUser", null);
        }else {
            map.put("createUser", userId);
        }
        return standingsTypeDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return standingsTypeDao.queryTotal(map);
    }

    @Override
    public int save(StandingsTypeEntity standingsType) {
        standingsType.setCreateUser(ShiroUtils.getUserId().intValue());
        standingsType.setCreateTime(new Date());
        return standingsTypeDao.save(standingsType);
    }

    @Override
    public int update(StandingsTypeEntity standingsType) {
        return standingsTypeDao.update(standingsType);
    }

    @Override
    public int delete(Integer id) {
        return standingsTypeDao.delete(id);
    }

    @Override
    public int deleteBatch(Integer[] ids) {
        return standingsTypeDao.deleteBatch(ids);
    }
}
